﻿using System.Collections.Generic;
using AutoMapper;
using LiaoChengFei.Core;
using LiaoChengFei.Services;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.Models;

namespace Swashbuckle.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class OrderController : ControllerBase
    {
        private readonly IMapper _mapper;

        public OrderController(IMapper mapper)
        {
            _mapper = mapper;
        }

        // GET: api/Orders
        [HttpGet]
        public IList<Orders> Get()
        {
            List<LiaoChengFei.DoMain.Orders> orders = EngineContext.Current.Resolve<IOrdersService>().GetOrders();
            List<Orders> dtoorders = new List<Orders>();
            _mapper.Map(orders, dtoorders);
            return dtoorders;
        }

        [HttpPost]
        public IActionResult Create([FromQuery]Orders orders)
        {
            List<LiaoChengFei.DoMain.Orders> dtoorders = new List<LiaoChengFei.DoMain.Orders>();
            _mapper.Map(orders, dtoorders);
            return new NoContentResult();
        }

        [HttpPost("{id}")]
        public IActionResult GetData(int id)
        {
            string aaa = Tools.GetData();
            return Content(aaa);
        }
    }
}
